<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.7"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>qLibc: containers/qtreetbl.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">qLibc
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.7 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('qtreetbl_8c.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">qtreetbl.c File Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Tree Table container that implements the Left-Leaning Red-Black BST algorithm.  
<a href="#details">More...</a></p>

<p><a href="qtreetbl_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a0a5c039995463a94bb7066190a6653e1"><td class="memItemLeft" align="right" valign="top">qtreetbl_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a0a5c039995463a94bb7066190a6653e1">qtreetbl</a> (int options)</td></tr>
<tr class="memdesc:a0a5c039995463a94bb7066190a6653e1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize a tree table.  <br /></td></tr>
<tr class="separator:a0a5c039995463a94bb7066190a6653e1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af9e239f384bd9939c34361a45dd496a6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#af9e239f384bd9939c34361a45dd496a6">qtreetbl_set_compare</a> (qtreetbl_t *tbl, int(*cmp)(const void *name1, size_t namesize1, const void *name2, size_t namesize2))</td></tr>
<tr class="memdesc:af9e239f384bd9939c34361a45dd496a6"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;set_compare(): Set user comparator.  <br /></td></tr>
<tr class="separator:af9e239f384bd9939c34361a45dd496a6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a49e05111c8541c7155e352fb618cf170"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a49e05111c8541c7155e352fb618cf170">qtreetbl_put</a> (qtreetbl_t *tbl, const char *name, const void *data, size_t datasize)</td></tr>
<tr class="memdesc:a49e05111c8541c7155e352fb618cf170"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;<a class="el" href="qhttpclient_8c.html#ae9ac3bd43c11509c0cbd8fb284bf13eb" title="qhttpclient-&gt;put(): Uploads a file to the remote host using PUT method.">put()</a>: Put an object into this table with string type key.  <br /></td></tr>
<tr class="separator:a49e05111c8541c7155e352fb618cf170"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a31e5908f6885033a58e354928e489b83"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a31e5908f6885033a58e354928e489b83">qtreetbl_putstr</a> (qtreetbl_t *tbl, const char *name, const char *str)</td></tr>
<tr class="memdesc:a31e5908f6885033a58e354928e489b83"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;putstr(): Put a string into this table.  <br /></td></tr>
<tr class="separator:a31e5908f6885033a58e354928e489b83"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac475383244c35814d0950f0fa0c6414e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#ac475383244c35814d0950f0fa0c6414e">qtreetbl_putstrf</a> (qtreetbl_t *tbl, const char *name, const char *format,...)</td></tr>
<tr class="memdesc:ac475383244c35814d0950f0fa0c6414e"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;putstrf(): Put a formatted string into this table.  <br /></td></tr>
<tr class="separator:ac475383244c35814d0950f0fa0c6414e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a74b90269930ae1607271c187514ac5e5"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a74b90269930ae1607271c187514ac5e5">qtreetbl_putobj</a> (qtreetbl_t *tbl, const void *name, size_t namesize, const void *data, size_t datasize)</td></tr>
<tr class="memdesc:a74b90269930ae1607271c187514ac5e5"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;putobj(): Put an object data into this table with an object key.  <br /></td></tr>
<tr class="separator:a74b90269930ae1607271c187514ac5e5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a106198f0800d8892e404e0020da0d685"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a106198f0800d8892e404e0020da0d685">qtreetbl_get</a> (qtreetbl_t *tbl, const char *name, size_t *datasize, bool newmem)</td></tr>
<tr class="memdesc:a106198f0800d8892e404e0020da0d685"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;<a class="el" href="qhttpclient_8c.html#af16a3eb0912e8b5d4896466632d9c843" title="qhttpclient-&gt;get(): Downloads a file from the remote host using GET method.">get()</a>: Get an object from this table.  <br /></td></tr>
<tr class="separator:a106198f0800d8892e404e0020da0d685"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a80185e2ca955ce2ccbdb43065110df4c"><td class="memItemLeft" align="right" valign="top">char *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a80185e2ca955ce2ccbdb43065110df4c">qtreetbl_getstr</a> (qtreetbl_t *tbl, const char *name, const bool newmem)</td></tr>
<tr class="memdesc:a80185e2ca955ce2ccbdb43065110df4c"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;getstr(): Finds an object and returns it as string type.  <br /></td></tr>
<tr class="separator:a80185e2ca955ce2ccbdb43065110df4c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a756340d5313f0ecf604c35326b3b6a5f"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a756340d5313f0ecf604c35326b3b6a5f">qtreetbl_getobj</a> (qtreetbl_t *tbl, const void *name, size_t namesize, size_t *datasize, bool newmem)</td></tr>
<tr class="memdesc:a756340d5313f0ecf604c35326b3b6a5f"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;getobj(): Get an object from this table with an object name.  <br /></td></tr>
<tr class="separator:a756340d5313f0ecf604c35326b3b6a5f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3354408a36cb5d6fd724727dda04d1f3"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a3354408a36cb5d6fd724727dda04d1f3">qtreetbl_remove</a> (qtreetbl_t *tbl, const char *name)</td></tr>
<tr class="memdesc:a3354408a36cb5d6fd724727dda04d1f3"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;remove(): Remove an object from this table.  <br /></td></tr>
<tr class="separator:a3354408a36cb5d6fd724727dda04d1f3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad3284afb03b64b8242687e33b87aaf0e"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#ad3284afb03b64b8242687e33b87aaf0e">qtreetbl_removeobj</a> (qtreetbl_t *tbl, const void *name, size_t namesize)</td></tr>
<tr class="memdesc:ad3284afb03b64b8242687e33b87aaf0e"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;remove(): Remove an object from this table with an object name.  <br /></td></tr>
<tr class="separator:ad3284afb03b64b8242687e33b87aaf0e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeb32bf5a193a0b7276cff302d3fcd090"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#aeb32bf5a193a0b7276cff302d3fcd090">qtreetbl_getnext</a> (qtreetbl_t *tbl, qtreetbl_obj_t *obj, const bool newmem)</td></tr>
<tr class="memdesc:aeb32bf5a193a0b7276cff302d3fcd090"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;getnext(): Get next element.  <br /></td></tr>
<tr class="separator:aeb32bf5a193a0b7276cff302d3fcd090"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac12b7b164b262053427eac34a2d1cbbc"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#ac12b7b164b262053427eac34a2d1cbbc">qtreetbl_find_min</a> (qtreetbl_t *tbl, size_t *namesize)</td></tr>
<tr class="memdesc:ac12b7b164b262053427eac34a2d1cbbc"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;find_min(): Find the name of the leftmost object.  <br /></td></tr>
<tr class="separator:ac12b7b164b262053427eac34a2d1cbbc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a590374e22090d003406210704b1c91d4"><td class="memItemLeft" align="right" valign="top">void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a590374e22090d003406210704b1c91d4">qtreetbl_find_max</a> (qtreetbl_t *tbl, size_t *namesize)</td></tr>
<tr class="memdesc:a590374e22090d003406210704b1c91d4"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;find_max(): Find the name of the rightmost object.  <br /></td></tr>
<tr class="separator:a590374e22090d003406210704b1c91d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa2c4f3ac4623feb251fadabbdf734bdd"><td class="memItemLeft" align="right" valign="top">qtreetbl_obj_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#aa2c4f3ac4623feb251fadabbdf734bdd">qtreetbl_find_nearest</a> (qtreetbl_t *tbl, const void *name, size_t namesize, bool newmem)</td></tr>
<tr class="memdesc:aa2c4f3ac4623feb251fadabbdf734bdd"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;find_nearest(): Find an object with matching key or nearest.  <br /></td></tr>
<tr class="separator:aa2c4f3ac4623feb251fadabbdf734bdd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3537212a86616d50459eec229d94f8e4"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a3537212a86616d50459eec229d94f8e4">qtreetbl_size</a> (qtreetbl_t *tbl)</td></tr>
<tr class="memdesc:a3537212a86616d50459eec229d94f8e4"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;size(): Returns the number of keys in the table.  <br /></td></tr>
<tr class="separator:a3537212a86616d50459eec229d94f8e4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7b324cf9e317a2623c5767b8a0183f72"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a7b324cf9e317a2623c5767b8a0183f72">qtreetbl_clear</a> (qtreetbl_t *tbl)</td></tr>
<tr class="memdesc:a7b324cf9e317a2623c5767b8a0183f72"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;clear(): Clears the table so that it contains no keys.  <br /></td></tr>
<tr class="separator:a7b324cf9e317a2623c5767b8a0183f72"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5c8aa458bac0dc5e7dc0ab97c6f52dfd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a5c8aa458bac0dc5e7dc0ab97c6f52dfd">qtreetbl_lock</a> (qtreetbl_t *tbl)</td></tr>
<tr class="memdesc:a5c8aa458bac0dc5e7dc0ab97c6f52dfd"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;lock(): Enter critical section.  <br /></td></tr>
<tr class="separator:a5c8aa458bac0dc5e7dc0ab97c6f52dfd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a88a8e67f478390c6b25780fda3134a8d"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a88a8e67f478390c6b25780fda3134a8d">qtreetbl_unlock</a> (qtreetbl_t *tbl)</td></tr>
<tr class="memdesc:a88a8e67f478390c6b25780fda3134a8d"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;unlock(): Leave critical section.  <br /></td></tr>
<tr class="separator:a88a8e67f478390c6b25780fda3134a8d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2bac240b706b85273338a26fb986eee7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a2bac240b706b85273338a26fb986eee7">qtreetbl_free</a> (qtreetbl_t *tbl)</td></tr>
<tr class="memdesc:a2bac240b706b85273338a26fb986eee7"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;free(): De-allocate the table.  <br /></td></tr>
<tr class="separator:a2bac240b706b85273338a26fb986eee7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a61a3463749adb906e549d51f8a9c5a51"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a61a3463749adb906e549d51f8a9c5a51">qtreetbl_byte_cmp</a> (const void *name1, size_t namesize1, const void *name2, size_t namesize2)</td></tr>
<tr class="separator:a61a3463749adb906e549d51f8a9c5a51"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a663dfe23addb8debd1c3da5e54d2c930"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a663dfe23addb8debd1c3da5e54d2c930">qtreetbl_debug</a> (qtreetbl_t *tbl, FILE *out)</td></tr>
<tr class="memdesc:a663dfe23addb8debd1c3da5e54d2c930"><td class="mdescLeft">&#160;</td><td class="mdescRight">qtreetbl-&gt;debug(): Print the internal tree structure in text.  <br /></td></tr>
<tr class="separator:a663dfe23addb8debd1c3da5e54d2c930"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a27db959def75174ccdab3fd073e8b8fc"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a27db959def75174ccdab3fd073e8b8fc">node_check_root</a> (qtreetbl_t *tbl)</td></tr>
<tr class="memdesc:a27db959def75174ccdab3fd073e8b8fc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Verifies that root property of the red-black tree is satisfied.  <br /></td></tr>
<tr class="separator:a27db959def75174ccdab3fd073e8b8fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acca3f6925989955eec665c5c9aa11ed2"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#acca3f6925989955eec665c5c9aa11ed2">node_check_red</a> (qtreetbl_t *tbl, qtreetbl_obj_t *obj)</td></tr>
<tr class="memdesc:acca3f6925989955eec665c5c9aa11ed2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Verifies that red property of the red-black tree is satisfied.  <br /></td></tr>
<tr class="separator:acca3f6925989955eec665c5c9aa11ed2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa727bb7c8a149d2b924d586594836d86"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#aa727bb7c8a149d2b924d586594836d86">node_check_black</a> (qtreetbl_t *tbl, qtreetbl_obj_t *obj, int *path_len)</td></tr>
<tr class="memdesc:aa727bb7c8a149d2b924d586594836d86"><td class="mdescLeft">&#160;</td><td class="mdescRight">Verifies that black property of the red-black tree is satisfied.  <br /></td></tr>
<tr class="separator:aa727bb7c8a149d2b924d586594836d86"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9d9d33c61cc0c7e3312c10504d628e98"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#a9d9d33c61cc0c7e3312c10504d628e98">node_check_llrb</a> (qtreetbl_t *tbl, qtreetbl_obj_t *obj)</td></tr>
<tr class="memdesc:a9d9d33c61cc0c7e3312c10504d628e98"><td class="mdescLeft">&#160;</td><td class="mdescRight">Verifies that LLRB property of the left-leaning red-black tree is satisfied.  <br /></td></tr>
<tr class="separator:a9d9d33c61cc0c7e3312c10504d628e98"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab53aff8d2c853903ecd90ff83eba2056"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="qtreetbl_8c.html#ab53aff8d2c853903ecd90ff83eba2056">qtreetbl_check</a> (qtreetbl_t *tbl)</td></tr>
<tr class="memdesc:ab53aff8d2c853903ecd90ff83eba2056"><td class="mdescLeft">&#160;</td><td class="mdescRight">Verifies that the invariants of the red-black tree are satisfied.  <br /></td></tr>
<tr class="separator:ab53aff8d2c853903ecd90ff83eba2056"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Tree Table container that implements the Left-Leaning Red-Black BST algorithm. </p>
<p>qtreetbl implements a binary search tree that allows efficient in-order traversal with O(log n) search time.</p>
<p>The algorithm qtreetbl specifically implements is the left-leaning red-black tree algorithm invented in 2008 by Robert Sedgewick. A left-leaning red–black tree is a type of self-balancing binary search tree and it is a variant of the red–black tree which was invented in 1972 by Rudolf Bayer.</p>
<p>References:</p><ul>
<li><a href="http://en.wikipedia.org/wiki/Left-leaning_red-black_tree">http://en.wikipedia.org/wiki/Left-leaning_red-black_tree</a></li>
<li><a href="https://sedgewick.io/wp-content/uploads/2022/03/2008-09LLRB.pdf">https://sedgewick.io/wp-content/uploads/2022/03/2008-09LLRB.pdf</a> <pre class="fragment">                         (E)
            ______________|______________
           /                             \
          (C)                           (R)
         /   \                         /   \
     (A,B)   (D)                   (I,N)   (S,X)

            &lt;2-3-4 Tree Data Structure&gt;

                          E
            ______________|______________
           /                             \
          C                               R
   _______|_______                 _______|_______
  /               \               /               \
 B                 D             N                 X
</pre> // // // A* I* S* <pre class="fragment">   &lt;Left-Leaning Red-Black Tree Data Structure&gt;
</pre> Nodes A, I and S are nodes with RED upper link. Others are BLACK</li>
</ul>
<p>The Red-Black BST algorithm has been one of the popular BST algorithms especially for in-memory operation. The Left-Leaning version of Red-Black especially improves performance and reduces overall complexity.</p>
<p>Since it's relatively new algorithm, there's not many practically functional working codes yet other than proof of concept kinds. Here's one of fully functional codes and I, Seungyoung Kim, would like to dedicate this code to the genius inventor Robert Sedgewick and to all the great qLibc users.</p>
<p>Additional features:</p><ul>
<li>iterator.</li>
<li>find nearest key.</li>
<li>iteration from given key.</li>
<li>find min/max key.</li>
</ul>
<div class="fragment"><div class="line">qtreetbl_t *tbl = <a class="code hl_function" href="qtreetbl_8c.html#a0a5c039995463a94bb7066190a6653e1">qtreetbl</a>(QTREETBL_THREADSAFE);</div>
<div class="line"> </div>
<div class="line">tbl-&gt;put(tbl, <span class="stringliteral">&quot;KEY&quot;</span>, <span class="stringliteral">&quot;DATA&quot;</span>, 4);          <span class="comment">// use putobj() for binary keys.</span></div>
<div class="line"><span class="keywordtype">void</span> *data = tbl-&gt;get(tbl, <span class="stringliteral">&quot;KEY&quot;</span>, <span class="keyword">false</span>); <span class="comment">// use getobj() for binary keys.</span></div>
<div class="line">tbl-&gt;remove(tbl, <span class="stringliteral">&quot;KEY&quot;</span>);                  <span class="comment">// use remove_by_key() for binary keys.</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// iteration example</span></div>
<div class="line">qtreetbl_obj_t obj;</div>
<div class="line">memset((<span class="keywordtype">void</span>*)&amp;obj, 0, <span class="keyword">sizeof</span>(obj)); <span class="comment">// must be cleared before call</span></div>
<div class="line">tbl-&gt;lock(tbl);  <span class="comment">// for thread safety</span></div>
<div class="line"><span class="keywordflow">while</span> (tbl-&gt;getnext(tbl, &amp;obj, <span class="keyword">false</span>) == <span class="keyword">true</span>) {</div>
<div class="line">  ...</div>
<div class="line">}</div>
<div class="line">tbl-&gt;unlock(tbl);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// find a nearest key then iterate from there</span></div>
<div class="line">tbl-&gt;lock(tbl);</div>
<div class="line">qtreetbl_obj_t obj = tbl-&gt;find_nearest(tbl, <span class="stringliteral">&quot;K&quot;</span>, <span class="keyword">sizeof</span>(<span class="stringliteral">&quot;K&quot;</span>), <span class="keyword">false</span>);</div>
<div class="line">tbl-&gt;lock(tbl);  <span class="comment">// for thread safety</span></div>
<div class="line"><span class="keywordflow">while</span> (tbl-&gt;getnext(tbl, &amp;obj, <span class="keyword">false</span>) == <span class="keyword">true</span>) {</div>
<div class="line">  ...</div>
<div class="line">}</div>
<div class="line">tbl-&gt;unlock(tbl);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// find minimum value using custom comparator</span></div>
<div class="line">tbl-&gt;set_compare(tbl, my_compare_func); <span class="comment">// default is byte comparator</span></div>
<div class="line"><span class="keywordtype">void</span> *min = tbl-&gt;find_min(tbl, &amp;keysize);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// get total number of objects in the table</span></div>
<div class="line"><span class="keywordtype">size_t</span> num = tbl-&gt;size(tbl);</div>
<div class="line"> </div>
<div class="line">tbl-&gt;free(tbl);</div>
<div class="ttc" id="aqtreetbl_8c_html_a0a5c039995463a94bb7066190a6653e1"><div class="ttname"><a href="qtreetbl_8c.html#a0a5c039995463a94bb7066190a6653e1">qtreetbl</a></div><div class="ttdeci">qtreetbl_t * qtreetbl(int options)</div><div class="ttdoc">Initialize a tree table.</div><div class="ttdef"><b>Definition</b> <a href="qtreetbl_8c_source.html#l00182">qtreetbl.c:182</a></div></div>
</div><!-- fragment --> 
<p class="definition">Definition in file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="a0a5c039995463a94bb7066190a6653e1" name="a0a5c039995463a94bb7066190a6653e1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0a5c039995463a94bb7066190a6653e1">&#9670;&#160;</a></span>qtreetbl()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">qtreetbl_t * qtreetbl </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>options</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize a tree table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">options</td><td>combination of initialization options.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of malloced qtreetbl_t, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOMEM : Memory allocation failure.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line">qtreetbl_t *tbl = <a class="code hl_function" href="qtreetbl_8c.html#a0a5c039995463a94bb7066190a6653e1">qtreetbl</a>(0);</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>Available options:<ul>
<li>QTREETBL_THREADSAFE - make it thread-safe. </li>
</ul>
</dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00182">182</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="af9e239f384bd9939c34361a45dd496a6" name="af9e239f384bd9939c34361a45dd496a6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af9e239f384bd9939c34361a45dd496a6">&#9670;&#160;</a></span>qtreetbl_set_compare()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qtreetbl_set_compare </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int(*)(const void *name1, size_t namesize1, const void *name2, size_t namesize2)&#160;</td>
          <td class="paramname"><em>cmp</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;set_compare(): Set user comparator. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">cmp</td><td>a pointer to the user comparator function.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>By default, qtreetbl uses byte comparator that works for both binary type key and string type key. Please refer qtreetbl_byte_cmp() for your idea to make your own comparator. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00250">250</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a49e05111c8541c7155e352fb618cf170" name="a49e05111c8541c7155e352fb618cf170"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a49e05111c8541c7155e352fb618cf170">&#9670;&#160;</a></span>qtreetbl_put()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qtreetbl_put </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>datasize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;<a class="el" href="qhttpclient_8c.html#ae9ac3bd43c11509c0cbd8fb284bf13eb" title="qhttpclient-&gt;put(): Uploads a file to the remote host using PUT method.">put()</a>: Put an object into this table with string type key. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key name. </td></tr>
    <tr><td class="paramname">data</td><td>data object. </td></tr>
    <tr><td class="paramname">datasize</td><td>size of data object.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00269">269</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a31e5908f6885033a58e354928e489b83" name="a31e5908f6885033a58e354928e489b83"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a31e5908f6885033a58e354928e489b83">&#9670;&#160;</a></span>qtreetbl_putstr()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qtreetbl_putstr </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>str</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;putstr(): Put a string into this table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key name. </td></tr>
    <tr><td class="paramname">str</td><td>string data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00287">287</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="ac475383244c35814d0950f0fa0c6414e" name="ac475383244c35814d0950f0fa0c6414e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac475383244c35814d0950f0fa0c6414e">&#9670;&#160;</a></span>qtreetbl_putstrf()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qtreetbl_putstrf </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>format</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>...</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;putstrf(): Put a formatted string into this table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key name. </td></tr>
    <tr><td class="paramname">format</td><td>formatted string data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00305">305</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a74b90269930ae1607271c187514ac5e5" name="a74b90269930ae1607271c187514ac5e5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a74b90269930ae1607271c187514ac5e5">&#9670;&#160;</a></span>qtreetbl_putobj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qtreetbl_putobj </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>namesize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>datasize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;putobj(): Put an object data into this table with an object key. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key name. </td></tr>
    <tr><td class="paramname">namesize</td><td>key size. </td></tr>
    <tr><td class="paramname">data</td><td>data object. </td></tr>
    <tr><td class="paramname">datasize</td><td>size of data object.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This is the underlying put function which all other put methods use. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00336">336</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a106198f0800d8892e404e0020da0d685" name="a106198f0800d8892e404e0020da0d685"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a106198f0800d8892e404e0020da0d685">&#9670;&#160;</a></span>qtreetbl_get()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * qtreetbl_get </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>datasize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>newmem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;<a class="el" href="qhttpclient_8c.html#af16a3eb0912e8b5d4896466632d9c843" title="qhttpclient-&gt;get(): Downloads a file from the remote host using GET method.">get()</a>: Get an object from this table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key name. </td></tr>
    <tr><td class="paramname">datasize</td><td>if not NULL, object size will be stored. </td></tr>
    <tr><td class="paramname">newmem</td><td>whether or not to allocate memory for the data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of data if the key is found, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No such key found.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line">qtreetbl_t *tbl = <a class="code hl_function" href="qtreetbl_8c.html#a0a5c039995463a94bb7066190a6653e1">qtreetbl</a>(0);</div>
<div class="line">(...codes...)</div>
<div class="line"> </div>
<div class="line"><span class="comment">// with newmem flag unset</span></div>
<div class="line"><span class="keywordtype">size_t</span> size;</div>
<div class="line"><span class="keywordtype">void</span> *data = (<span class="keyword">struct </span>myobj*)tbl-&gt;get(tbl, <span class="stringliteral">&quot;key_name&quot;</span>, &amp;size, <span class="keyword">false</span>);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// with newmem flag set</span></div>
<div class="line"><span class="keywordtype">size_t</span> size;</div>
<div class="line"><span class="keywordtype">void</span> *data  = (<span class="keyword">struct </span>myobj*)tbl-&gt;get(tbl, <span class="stringliteral">&quot;key_name&quot;</span>, &amp;size, <span class="keyword">true</span>);</div>
<div class="line">free(data);</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>If newmem flag is set, returned data will be malloced and should be deallocated by user. Otherwise returned pointer will point internal buffer directly and should not be de-allocated by user. In thread-safe mode, newmem flag must be set to true always. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00392">392</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a80185e2ca955ce2ccbdb43065110df4c" name="a80185e2ca955ce2ccbdb43065110df4c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a80185e2ca955ce2ccbdb43065110df4c">&#9670;&#160;</a></span>qtreetbl_getstr()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char * qtreetbl_getstr </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const bool&#160;</td>
          <td class="paramname"><em>newmem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;getstr(): Finds an object and returns it as string type. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key name. </td></tr>
    <tr><td class="paramname">newmem</td><td>whether or not to allocate memory for the data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer to data if the key is found, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No such key found.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>If newmem flag is set, returned data will be malloced and should be deallocated by user. Otherwise returned pointer will point internal buffer directly and should not be de-allocated by user. In thread-safe mode, newmem flag must be set to true always. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00417">417</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a756340d5313f0ecf604c35326b3b6a5f" name="a756340d5313f0ecf604c35326b3b6a5f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a756340d5313f0ecf604c35326b3b6a5f">&#9670;&#160;</a></span>qtreetbl_getobj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * qtreetbl_getobj </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>namesize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>datasize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>newmem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;getobj(): Get an object from this table with an object name. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key name. </td></tr>
    <tr><td class="paramname">namesize</td><td>key size. </td></tr>
    <tr><td class="paramname">datasize</td><td>if not NULL, oject size will be stored. </td></tr>
    <tr><td class="paramname">newmem</td><td>whether or not to allocate memory for the data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>a pointer of data if the key is found, otherwise returns NULL. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No such key found.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>If newmem flag is set, returned data will be malloced and should be deallocated by user. Otherwise returned pointer will point internal buffer directly and should not be de-allocated by user. In thread-safe mode, newmem flag must be set to true always. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00443">443</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a3354408a36cb5d6fd724727dda04d1f3" name="a3354408a36cb5d6fd724727dda04d1f3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3354408a36cb5d6fd724727dda04d1f3">&#9670;&#160;</a></span>qtreetbl_remove()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qtreetbl_remove </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;remove(): Remove an object from this table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key name.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise(not found) returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No such key found.</li>
<li>EINVAL : Invalid argument. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00474">474</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="ad3284afb03b64b8242687e33b87aaf0e" name="ad3284afb03b64b8242687e33b87aaf0e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad3284afb03b64b8242687e33b87aaf0e">&#9670;&#160;</a></span>qtreetbl_removeobj()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qtreetbl_removeobj </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>namesize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;remove(): Remove an object from this table with an object name. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key name. </td></tr>
    <tr><td class="paramname">name</td><td>key size.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise(not found) returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No such key found.</li>
<li>EINVAL : Invalid argument. </li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00491">491</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="aeb32bf5a193a0b7276cff302d3fcd090" name="aeb32bf5a193a0b7276cff302d3fcd090"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeb32bf5a193a0b7276cff302d3fcd090">&#9670;&#160;</a></span>qtreetbl_getnext()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qtreetbl_getnext </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">qtreetbl_obj_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const bool&#160;</td>
          <td class="paramname"><em>newmem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;getnext(): Get next element. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">obj</td><td>found data will be stored in this object. </td></tr>
    <tr><td class="paramname">newmem</td><td>whether or not to allocate memory for the data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if found otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No next element.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line">[Iteration example from the beginning]</div>
<div class="line"> </div>
<div class="line">qtreetbl_obj_t obj;</div>
<div class="line">memset((<span class="keywordtype">void</span>*)&amp;obj, 0, <span class="keyword">sizeof</span>(obj)); <span class="comment">// must be cleared before call</span></div>
<div class="line">tbl-&gt;lock(tbl);  <span class="comment">// lock it when thread condition is expected</span></div>
<div class="line"><span class="keywordflow">while</span>(tbl-&gt;getnext(tbl, &amp;obj, <span class="keyword">false</span>) == <span class="keyword">true</span>) {</div>
<div class="line">   <span class="comment">//</span></div>
<div class="line">   <span class="comment">// obj.name     : key data</span></div>
<div class="line">   <span class="comment">// obj.namesize : key size</span></div>
<div class="line">   <span class="comment">// obj.data     : data</span></div>
<div class="line">   <span class="comment">// obj.datasize : data size</span></div>
<div class="line">   <span class="comment">//</span></div>
<div class="line">   <span class="comment">// Do free obj.name and obj.data if newmem is set to true;</span></div>
<div class="line">}</div>
<div class="line">tbl-&gt;unlock(tbl);</div>
</div><!-- fragment --><div class="fragment"><div class="line">[Iteration example from given point]</div>
<div class="line"> </div>
<div class="line">tbl-&gt;lock(tbl);  <span class="comment">// to guarantee no table update during the run</span></div>
<div class="line">qtreetbl_obj_t obj = tbl-&gt;find_nearest(tbl, <span class="stringliteral">&quot;F&quot;</span>, <span class="keyword">sizeof</span>(<span class="stringliteral">&quot;F&quot;</span>), <span class="keyword">false</span>);</div>
<div class="line"><span class="keywordflow">while</span> (tbl-&gt;getnext(tbl, &amp;obj, <span class="keyword">false</span>) == <span class="keyword">true</span>) {  <span class="comment">// newmem is false</span></div>
<div class="line">    <span class="comment">// If a tree has 5 objects, A, C, E, G and I.</span></div>
<div class="line">    <span class="comment">// The iteration sequence from nearest &quot;F&quot; will be: E-&gt;G-&gt;I-&gt;A-&gt;C</span></div>
<div class="line">}</div>
<div class="line">tbl-&gt;unlock(tbl);</div>
</div><!-- fragment --><div class="fragment"><div class="line">[Removal example in iteration loop]</div>
<div class="line"> </div>
<div class="line">qtreetbl_obj_t obj;</div>
<div class="line">memset((<span class="keywordtype">void</span>*)&amp;obj, 0, <span class="keyword">sizeof</span>(obj));</div>
<div class="line">tbl-&gt;lock(tbl);</div>
<div class="line"><span class="keywordflow">while</span> (tbl-&gt;getnext(tbl, &amp;obj, <span class="keyword">false</span>) == <span class="keyword">true</span>) {</div>
<div class="line">    <span class="keywordflow">if</span> (...condition...) {</div>
<div class="line">        <span class="keywordtype">char</span> *name = <a class="code hl_function" href="qstring_8c.html#aa27b0a87aa68e3ee318e3280a5f9d9d5">qmemdup</a>(obj.name, obj.namesize);  <span class="comment">// keep the name</span></div>
<div class="line">        <span class="keywordtype">size_t</span> namesize = obj.namesize;                <span class="comment">// for removal argument</span></div>
<div class="line">        tbl-&gt;removeobj(tbl, obj.name, obj.namesize);   <span class="comment">// remove</span></div>
<div class="line">        obj = tbl-&gt;find_nearest(tbl, name, namesize, <span class="keyword">false</span>); <span class="comment">// rewind one step back</span></div>
<div class="line">        free(name);  <span class="comment">// clean up</span></div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line">tbl-&gt;unlock(tbl);</div>
<div class="ttc" id="aqstring_8c_html_aa27b0a87aa68e3ee318e3280a5f9d9d5"><div class="ttname"><a href="qstring_8c.html#aa27b0a87aa68e3ee318e3280a5f9d9d5">qmemdup</a></div><div class="ttdeci">void * qmemdup(const void *data, size_t size)</div><div class="ttdoc">Duplicate a copy of memory data.</div><div class="ttdef"><b>Definition</b> <a href="qstring_8c_source.html#l00413">qstring.c:413</a></div></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li>Data insertion or deletion can be made during the traversal, but in that case iterator doesn't guarantee full sweep and possibly skip some visits. When deletion happens in getnext() loop, use find_nearest() to rewind the iterator one step back.</li>
<li>Object obj should be initialized with 0 by using memset() before first call.</li>
<li>If newmem flag is true, user should de-allocate obj.name and obj.data resources. </li>
</ul>
</dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00580">580</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="ac12b7b164b262053427eac34a2d1cbbc" name="ac12b7b164b262053427eac34a2d1cbbc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ac12b7b164b262053427eac34a2d1cbbc">&#9670;&#160;</a></span>qtreetbl_find_min()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * qtreetbl_find_min </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>namesize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;find_min(): Find the name of the leftmost object. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">namesize</td><td>if not NULL, the size of key name will be stored.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>malloced memory copying the key name.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>It's user's responsibility to free the return. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00634">634</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a590374e22090d003406210704b1c91d4" name="a590374e22090d003406210704b1c91d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a590374e22090d003406210704b1c91d4">&#9670;&#160;</a></span>qtreetbl_find_max()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void * qtreetbl_find_max </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t *&#160;</td>
          <td class="paramname"><em>namesize</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;find_max(): Find the name of the rightmost object. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">namesize</td><td>if not NULL, the size of key name will be stored.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>malloced memory copying the key name.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>It's user's responsibility to free the return. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00662">662</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="aa2c4f3ac4623feb251fadabbdf734bdd" name="aa2c4f3ac4623feb251fadabbdf734bdd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa2c4f3ac4623feb251fadabbdf734bdd">&#9670;&#160;</a></span>qtreetbl_find_nearest()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">qtreetbl_obj_t qtreetbl_find_nearest </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>namesize</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>newmem</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;find_nearest(): Find an object with matching key or nearest. </p>
<p>find_nearest() returns matching key or nearest key object. If there's no keys in the table. It'll return empty qtreetbl_obj_t object with errno ENOENT.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">name</td><td>key name. </td></tr>
    <tr><td class="paramname">namesize</td><td>key size. </td></tr>
    <tr><td class="paramname">newmem</td><td>whether or not to allocate memory for the data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>qtreetbl_obj_t object.</dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>ENOENT : No next element.</li>
<li>EINVAL : Invalid argument.</li>
<li>ENOMEM : Memory allocation failure.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line">Data Set : A B C D E I N R S X</div>
<div class="line">find_nearest(<span class="stringliteral">&quot;0&quot;</span>) =&gt; <span class="stringliteral">&quot;A&quot;</span> <span class="comment">// no smaller key available, so &quot;A&quot;</span></div>
<div class="line">find_nearest(<span class="stringliteral">&quot;C&quot;</span>) =&gt; <span class="stringliteral">&quot;C&quot;</span> <span class="comment">// matching key found</span></div>
<div class="line">find_nearest(<span class="stringliteral">&quot;F&quot;</span>) =&gt; <span class="stringliteral">&quot;E&quot;</span> <span class="comment">// &quot;E&quot; is nearest smaller key from &quot;F&quot;</span></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>When there's no matching key it look for closest smaller key in the neighbors. The only exception when it returns bigger key than given search key is that when there's no smaller keys available in the table. In such case, it'll return the nearest bigger key. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00711">711</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a3537212a86616d50459eec229d94f8e4" name="a3537212a86616d50459eec229d94f8e4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3537212a86616d50459eec229d94f8e4">&#9670;&#160;</a></span>qtreetbl_size()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">size_t qtreetbl_size </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;size(): Returns the number of keys in the table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>number of elements stored. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00775">775</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a7b324cf9e317a2623c5767b8a0183f72" name="a7b324cf9e317a2623c5767b8a0183f72"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7b324cf9e317a2623c5767b8a0183f72">&#9670;&#160;</a></span>qtreetbl_clear()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qtreetbl_clear </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;clear(): Clears the table so that it contains no keys. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00784">784</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a5c8aa458bac0dc5e7dc0ab97c6f52dfd" name="a5c8aa458bac0dc5e7dc0ab97c6f52dfd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5c8aa458bac0dc5e7dc0ab97c6f52dfd">&#9670;&#160;</a></span>qtreetbl_lock()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qtreetbl_lock </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;lock(): Enter critical section. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>From user side, normally locking operation is only needed when traverse all elements using qtreetbl-&gt;getnext().</dd>
<dd>
This operation will do nothing if QTREETBL_THREADSAFE option was not given at the initialization time. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00805">805</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a88a8e67f478390c6b25780fda3134a8d" name="a88a8e67f478390c6b25780fda3134a8d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a88a8e67f478390c6b25780fda3134a8d">&#9670;&#160;</a></span>qtreetbl_unlock()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qtreetbl_unlock </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;unlock(): Leave critical section. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>This operation will do nothing if QTREETBL_THREADSAFE option was not given at the initialization time. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00818">818</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a2bac240b706b85273338a26fb986eee7" name="a2bac240b706b85273338a26fb986eee7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2bac240b706b85273338a26fb986eee7">&#9670;&#160;</a></span>qtreetbl_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void qtreetbl_free </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;free(): De-allocate the table. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00827">827</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a61a3463749adb906e549d51f8a9c5a51" name="a61a3463749adb906e549d51f8a9c5a51"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a61a3463749adb906e549d51f8a9c5a51">&#9670;&#160;</a></span>qtreetbl_byte_cmp()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int qtreetbl_byte_cmp </td>
          <td>(</td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>name1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>namesize1</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const void *&#160;</td>
          <td class="paramname"><em>name2</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>namesize2</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00833">833</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a663dfe23addb8debd1c3da5e54d2c930" name="a663dfe23addb8debd1c3da5e54d2c930"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a663dfe23addb8debd1c3da5e54d2c930">&#9670;&#160;</a></span>qtreetbl_debug()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool qtreetbl_debug </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FILE *&#160;</td>
          <td class="paramname"><em>out</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>qtreetbl-&gt;debug(): Print the internal tree structure in text. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">out</td><td>output stream.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>true if successful, otherwise returns false. </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">errno</td><td>will be set in error condition.<ul>
<li>EIO : Invalid output stream.</li>
</ul>
</td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line">Example output:</div>
<div class="line"> </div>
<div class="line">    ┌───9</div>
<div class="line">    │   └──[8]</div>
<div class="line">┌───7</div>
<div class="line">│   │   ┌───6</div>
<div class="line">│   └──[5]</div>
<div class="line">│       └───4</div>
<div class="line">3</div>
<div class="line">│   ┌───2</div>
<div class="line">└───1</div>
<div class="line">    └───0</div>
</div><!-- fragment --> <dl class="section note"><dt>Note</dt><dd>Red nodes are wrapped in <code>[]</code>. In this example, 5 and 8 are Red nodes. </dd></dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00871">871</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a27db959def75174ccdab3fd073e8b8fc" name="a27db959def75174ccdab3fd073e8b8fc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a27db959def75174ccdab3fd073e8b8fc">&#9670;&#160;</a></span>node_check_root()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int node_check_root </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Verifies that root property of the red-black tree is satisfied. </p>
<p>Root property: The root is black.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00890">890</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="acca3f6925989955eec665c5c9aa11ed2" name="acca3f6925989955eec665c5c9aa11ed2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acca3f6925989955eec665c5c9aa11ed2">&#9670;&#160;</a></span>node_check_red()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int node_check_red </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">qtreetbl_obj_t *&#160;</td>
          <td class="paramname"><em>obj</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Verifies that red property of the red-black tree is satisfied. </p>
<p>Red property: If a node is red, then both its children are black.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">obj</td><td>qtreetbl_obj_t object pointer. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00909">909</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="aa727bb7c8a149d2b924d586594836d86" name="aa727bb7c8a149d2b924d586594836d86"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa727bb7c8a149d2b924d586594836d86">&#9670;&#160;</a></span>node_check_black()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int node_check_black </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">qtreetbl_obj_t *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>path_len</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Verifies that black property of the red-black tree is satisfied. </p>
<p>Black property: For each node, all simple paths from the node to descendant leaves contain the same number of black nodes.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">obj</td><td>qtreetbl_obj_t object pointer. </td></tr>
    <tr><td class="paramname">path_len</td><td>black path length. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00940">940</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="a9d9d33c61cc0c7e3312c10504d628e98" name="a9d9d33c61cc0c7e3312c10504d628e98"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9d9d33c61cc0c7e3312c10504d628e98">&#9670;&#160;</a></span>node_check_llrb()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int node_check_llrb </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">qtreetbl_obj_t *&#160;</td>
          <td class="paramname"><em>obj</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Verifies that LLRB property of the left-leaning red-black tree is satisfied. </p>
<p>LLRB property: 3-nodes always lean to the left and 4-nodes are balanced.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
    <tr><td class="paramname">obj</td><td>qtreetbl_obj_t object pointer. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l00971">971</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
<a id="ab53aff8d2c853903ecd90ff83eba2056" name="ab53aff8d2c853903ecd90ff83eba2056"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab53aff8d2c853903ecd90ff83eba2056">&#9670;&#160;</a></span>qtreetbl_check()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int qtreetbl_check </td>
          <td>(</td>
          <td class="paramtype">qtreetbl_t *&#160;</td>
          <td class="paramname"><em>tbl</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Verifies that the invariants of the red-black tree are satisfied. </p>
<p>Root property: The root is black. Red property: If a node is red, then both its children are black. Black property: For each node, all simple paths from the node to descendant leaves contain the same number of black nodes. LLRB property: 3-nodes always lean to the left and 4-nodes are balanced.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tbl</td><td>qtreetbl_t container pointer. </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="qtreetbl_8c_source.html#l01001">1001</a> of file <a class="el" href="qtreetbl_8c_source.html">qtreetbl.c</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_0b61c55142250c0cc363383afd8075a4.html">containers</a></li><li class="navelem"><a class="el" href="qtreetbl_8c.html">qtreetbl.c</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.7 </li>
  </ul>
</div>
</body>
</html>
